﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using YArchitech.LIB;
using HYRevitCode.FormUtility;

namespace QuickModel.Forms.RoomTransModelForms
{
	public partial class MainForm : System.Windows.Forms.Form
	{
		public CloseDlgType CloseDlgType
		{
			get
			{
				return this.m_closeDlgType;
			}
		}

		public List<string> SelectedLayer
		{
			get
			{
				return this.m_lstSelectLayer;
			}
			set
			{
				this.m_lstSelectLayer = value;
			}
		}

		public MainForm()
		{
			this.InitializeComponent();
			this.m_ctrlManager = new ControlInfoManager(this, new List<KeyValuePair<System.Windows.Forms.Control, bool>>(), null, null);
		}

		private void SetText()
		{
			this.lblNum.Text = string.Format("已选择 {0} 个参考图元", this.m_lstSelectLayer.Count);
			this.lblNum.ForeColor = (this.m_lstSelectLayer.IsEmpty<string>() ? System.Drawing.Color.Black : System.Drawing.Color.Green);
			this.pictureBox1.Visible = !this.m_lstSelectLayer.IsEmpty<string>();
		}

		private void SetControlEnable()
		{
			bool enabled = false;
			bool flag = !this.m_lstSelectLayer.IsEmpty<string>();
			if (flag)
			{
				enabled = true;
			}
			this.btnOverall.Enabled = enabled;
			this.butLocal.Enabled = enabled;
		}

		private void SetToolTip()
		{
			string text = "已选择图层：\n";
			for (int i = 0; i < this.m_lstSelectLayer.Count; i++)
			{
				text = text + this.m_lstSelectLayer[i] + "\n";
			}
			this.toolTipSelectedLayerName.SetToolTip(this.btnSelectRoom, text);
		}

		private void butCancel_Click(object sender, EventArgs e)
		{
			this.m_closeDlgType = CloseDlgType.RT_Otheer;
			base.DialogResult = DialogResult.Cancel;
		}

		private void picSetting_Click(object sender, EventArgs e)
		{
			this.m_closeDlgType = CloseDlgType.RT_SetupParam;
			base.DialogResult = DialogResult.OK;
		}

		private void btnOverall_Click(object sender, EventArgs e)
		{
			this.m_closeDlgType = CloseDlgType.RT_TransForLevel;
			base.DialogResult = DialogResult.OK;
		}

		private void MainForm_Load(object sender, EventArgs e)
		{
			base.Icon = Resource.YArchitechIcon;
			bool flag = this.m_ctrlManager != null;
			if (flag)
			{
				this.m_ctrlManager.SetControlInfoToForm();
			}
			this.SetControlEnable();
			this.SetToolTip();
			this.SetText();
		}

		private void btnSelectRoom_Click(object sender, EventArgs e)
		{
			this.m_closeDlgType = CloseDlgType.RT_SelectRoomName;
			base.DialogResult = DialogResult.OK;
		}

		private void picEmpty_Click(object sender, EventArgs e)
		{
			this.m_closeDlgType = CloseDlgType.RT_Clear;
			base.DialogResult = DialogResult.OK;
		}

		private void butLocal_Click(object sender, EventArgs e)
		{
			this.m_closeDlgType = CloseDlgType.RT_TransForLocal;
			base.DialogResult = DialogResult.OK;
		}

		private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
		{
			bool flag = this.m_ctrlManager != null;
			if (flag)
			{
				this.m_ctrlManager.GetControlInfoToXml();
			}
		}

		private void lblNum_Click(object sender, EventArgs e)
		{
		}

		private CloseDlgType m_closeDlgType = CloseDlgType.RT_Otheer;

		private List<string> m_lstSelectLayer = new List<string>();

		private ControlInfoManager m_ctrlManager = null;
	}
}
